import { defineStore } from "pinia";
import { Names } from "../../store-namespace";
import { _get, _post, _put, _delete, http } from "@/utils/axios";
import { LineCruiseTasks } from "@/api/backend/index";

export const useLineCruiseTask = defineStore(Names.LineCruiseTask, {
  state: () => {
    return {
      loading: false,
      query: "", //设备接入企业的id
      single: {
        createBy: null,
        createTime: "",
        employeeId: 0,
        employeeName: "",
        employees: [],
        employeesList: null,
        endTime: "",
        equipmentInfoList: [],
        id: 0,
        params: {},
        planName: "",
        planNumber: "",
        realmanId: null,
        realmanIds: [],
        realmanName: null,
        remark: null,
        searchValue: null,
        startTime: "",
        state: 0,
        taskEnd: null,
        taskStart: null,
        updateBy: null,
        updateTime: null,
      }, //单个任务详情
    };
  },
  getters: {},
  actions: {
    //获取巡检任务数据
    getSingleAndListTasksAuto(filter: any) {
      return new Promise((resolve, reject) => {
        _get(LineCruiseTasks + "/list", filter, "json", "").then((res) => {
          console.log("获取巡检任务数据", res);
          resolve(res);
        });
      });
    },
    // getDept() {
    //   return new Promise((resolve, reject) => {
    //     _get(sysMDept + "/treeselect", {}, "json", "")
    //       .then((res) => {
    //         console.log(res);
    //         resolve(res);
    //       })
    //       .catch((err) => {
    //         console.log(err);
    //         reject(err);
    //       });
    //   });
    // },
  },
});
